//引入fs模块
const fs = require("fs");

fs.readFile('./resourse/为学.md', (err, data1) => {
    fs.readFile('./resourse/为学2.md', (err, data2) => {
        fs.readFile('./resourse/为学3.md', (err, data3) => {
            let result = data1 + `\n` + data2 + `\n` + data3;
            console.log(result);
        });
    });
});

//使用Promise 实现
const p = new Promise((resolve, reject) => {
    fs.readFile('./resourse/为学.md', (err, data1) => {
        resolve(data);
    });
});

p.then(value => {
    return new Promise((resolve, reject) => {
        fs.readFile('./resoure/为学2.md', (err, data) => {
            resolve([value, data]);
        });
    })
}).then(value =>{
    return new Promise((resolve, reject) => {
        fs.readFile('./resoure/为学3.md', (err, data) => {
            //压入
            value.push(data);
            resolve(value);
        });
    })
}).then(value=>{
    console.log(value.join('\r\n'));
});